<template>
    <div class="modal fade" id="toM2Modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          	<div class="modal-header">
            	<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            	<h4 class="modal-title" id="myModalLabel">转客</h4>
          	</div>
          	<div class="modal-body">
          	 	<div class="form-horizontal">
					<div class="form-group">
						<label class="col-md-4 col-sm-2 control-label">客户姓名：</label>
						<div class="col-md-8 col-sm-10">
							<div class="form-control">
								{{this.m2Modal.name}}
							</div>
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-4 col-sm-2 control-label">客户电话：</label>
						<div class="col-md-8 col-sm-10">
							<div class="form-control">
								{{this.m2Modal.mobile}}
							</div>
						</div>
					</div>
					<div class="form-group">
						<label class="col-md-4 col-sm-2 control-label">转到项目：</label>
						<div class="col-md-8 col-sm-10">
							<div class="form-control">
								{{this.m2Modal.premisesName}}
							</div>
						</div>
					</div>
	                <div class="form-group">
	                  <label for="" class="col-sm-4 control-label">备注信息：</label>
	                  <div class="col-sm-8">
	                    <textarea rows="5" class="form-control" v-model="params.remark" placeholder="请填写备注信息"></textarea>
	                  </div>
	                </div>
	            </div>
          	</div>
          	<div class="modal-footer">
            	<button type="button" class="btn checkedBtn" :disabled="disabledFlag"  @click="save">确定</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
          	</div>
        </div>
      </div>
    </div>
</template>

<script>
	export default{
		//接收父组件的绑定值
		props: ["m2Modal"],
		data() {
			return {
				//机构信息对象
				params: {
                    cusPreId:'',
					remark: ''
				},
				disabledFlag: false
			}
		},
		methods: {
            save: function() {
                const _self = this;
                _self.disabledFlag = true;
                const url = this.utilHelper.apiUrl+'/api/customerToM2';
                const body = {};
                _self.params.cusPreId = this.m2Modal.id;
                body.params = _self.params;
                _self.$http.post(url,body).then((response) =>{
                    const res = response.body.resData;
                    _self.disabledFlag = false;
                    if(res && res.result == '1') {
                        layer.msg("转客成功");
                        $('#toM2Modal').modal('hide');
                        _self.$emit('saveM2Listener');
                    }else {
                        layer.msg("转客失败");
                    }
                },(response)=>{
                	_self.disabledFlag = false;
                    layer.msg("系统异常");
                });
			}
		}
	}
</script>